# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=ddclient
pkgver=3.11.2
pkgrel=0
pkgdesc="Ddclient is a Perl client used to update dynamic DNS entries for accounts on 'Dynamic DNS Network Services' free DNS service."
url="https://ddclient.net/"
arch="noarch"
license="GPL-2.0-only"
depends="curl net-tools perl perl-digest-sha1"
makedepends="autoconf automake"
checkdepends="perl-sub-identify perl-test-mockmodule perl-test-warnings"
pkgusers="$pkgname"
pkggroups="$pkgname"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/ddclient/ddclient/archive/v$pkgver.tar.gz
	$pkgname.initd

	skip-valid-ipv6-test.patch
	"

prepare() {
	default_prepare
	./autogen
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc/ddclient \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--runstatedir=/run/ddclient
	make
}

check() {
	make VERBOSE=1 check
}

package() {
	make DESTDIR="$pkgdir" install

	chown -R $pkgusers:$pkggroups "$pkgdir"/var/cache/ddclient
	install -Dm755 $srcdir/ddclient.initd "$pkgdir"/etc/init.d/$pkgname
	chmod 600 "$pkgdir"/etc/ddclient/ddclient.conf
	chown $pkgusers:$pkggroups "$pkgdir"/etc/ddclient

	install -Dm644 -t "$pkgdir"/usr/share/doc/$pkgname/ \
		sample-etc_cron.d_ddclient \
		sample-etc_dhclient-exit-hooks \
		sample-etc_ppp_ip-up.local
}

doc() {
	default_doc
	pkgdesc="$pkgname documentation"
}

sha512sums="
b0d275f5ccc36cd8b532b6176de885696ff189dbdffa71bc63e9fa6db2aaf4ab5ff3290c251e318f05b2163c546dcc785eb3582388d9fb70e8439e35e5cbcd7f  ddclient-3.11.2.tar.gz
c5a4c4aef817692f73272a8aaf6edb10d3b16272577ef83c1f5db32b806933c410c7da0a7ce138655282a0671a8590879d6fe7c8f58f64c5cedfc1ed1cac710b  ddclient.initd
26170c796e25d5d88acc617b1ad79e467a1173d7c43ce662d668a5ee21ff7206e60e482beee18e46c59c955dadbeb2a8f9960f2b9f4c8d565492aa912be00719  skip-valid-ipv6-test.patch
"
